<script>
  function ajaxPromise() {
    return new Promise(function (resolve, reject) {
      const xhr = new XMLHttpRequest()
      xhr.onreadystatechange = function () {
        if (xhr.readyState === 4) {
          if (xhr.status === 200) {
            let { g: res } = JSON.parse(xhr.responseText)
            resolve(res)
          } else {
            reject(xhr.status)
          }
        }
      }
      xhr.open("get", `http://www.baidu.com/sugrec?prod=pc&wd=html`)
      xhr.send(null)
    })
  }

  Promise.all([ajaxPromise(), ajaxPromise()]).then(
    (res) => {
      console.log("all success", res)
    },
    (err) => {
      console.log("something wrong", res)
    }
  )
</script>
